<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Db
 *
 * @author Alisson Chiquitto<chiquitto@chiquitto.com.br>
 */
class ZFKiller_Auth_Adapter_Http_Resolver_Db implements Zend_Auth_Adapter_Http_Resolver_Interface {

    /**
     *
     * @var ZFKiller_Db_Table
     */
    private $_table;

    /**
     *
     * @var string
     */
    private $_identityColumn;

    /**
     *
     * @var string
     */
    private $_credentialColumn;

    public function __construct(ZFKiller_Db_Table $table, $identityColumn, $credentialColumn) {
        $this->_table = $table;
        $this->_identityColumn = $identityColumn;
        $this->_credentialColumn = $credentialColumn;
    }

    /**
     * 
     * @param string $username
     * @param string $realm Senha
     * @return Zend_Db_Table_Row_Abstract
     */
    public function resolve($username, $realm) {
        $adapter = $this->_table->getAdapter();
        return $this->_table->fetchRow(array(
            $adapter->quoteInto("{$this->_identityColumn} = ?", $username),
            $adapter->quoteInto("{$this->_credentialColumn} = ?", $realm),
        ));
        return $row;
    }

}